package Default;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;

import javax.swing.JPanel;

public class ResultPanel extends JPanel{
	
	Manager manager;
	
	public ResultPanel(Manager _manager)
	{
		manager=_manager;
		setPreferredSize(new Dimension(1000,800));
	}
	
	public void paint(Graphics g) {
		Agent agent,agent2;
		int d;
		g.setColor(Color.lightGray);
		g.drawLine(0, 791, 1000, 791);
		g.setColor(Color.red);
		for(int i=0;i<manager.superNodes.size();i++)
		{
			agent=manager.superNodes.get(i);
			//System.out.println(agent.connect.allAgentUnderMe);
			for(int j=0;j<agent.connect.allAgentUnderMe.size();j++)
			{
				agent2=manager.all_agents.get(agent.connect.allAgentUnderMe.get(j)-1);
				d=(int)calcDistance(agent.position, agent2.position);
			//	System.out.println("id: "+agent2.ID+" d: "+d+" battery: "+agent2.battery);
				g.fillOval(d*5, (int)(790-agent2.battery/10), 2, 2);
			}
		}
	}
	
	public double calcDistance(Point p1,Point p2)
	{
		double x=Math.abs(p1.x-p2.x);
		double y=Math.abs(p1.y-p2.y);
		double d=Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
		return d;
	}

}
